﻿using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraCharts;
using Zero.POCO.Views;

namespace DevExpress.MailClient.Win.Controls.ProfilPenetration {
    public partial class WidgetInstruction : UserControl {
        Timer updateTimer = new Timer();
        static Color positiveColor = Color.FromArgb(70, 158, 165);
        static Color negativeColor = Color.FromArgb(165, 70, 113);
        public WidgetInstruction()
        {
            InitializeComponent();
            updateTimer.Interval = 1000;
            updateTimer.Tick += OnTimerTick;
            updateTimer.Start();
            OnTimerTick(this, EventArgs.Empty);
        }
     
        int index = 0;
       // StockData previousData;
        void OnTimerTick(object sender, EventArgs e) {
          /*  if(IsDisposed) { updateTimer.Stop(); return; }
            StockData data = StockDataCreator.GetData(index);
            if(index > 0) {
                decimal d = data.ClosePrice - previousData.ClosePrice;
                decimal dq = (d * 100) / data.ClosePrice;
                labelControl5.Text = Math.Round( d, 2, MidpointRounding.ToEven).ToString().TrimEnd('0');
                stateIndicatorComponent1.StateIndex =  previousData.ClosePrice - data.ClosePrice < 0 ? 0 : 1;
                if(stateIndicatorComponent1.StateIndex == 0) {
                    labelControl5.ForeColor = positiveColor;
                    labelControl2.Text = data.ClosePrice.ToString().TrimEnd('0') + "<br><color=70,158,165>" + Math.Round(dq, 2, MidpointRounding.ToEven).ToString().TrimEnd('0') + '%';
                }
                else {
                    labelControl5.ForeColor = negativeColor;
                    labelControl2.Text = data.ClosePrice.ToString().TrimEnd('0') + "<br><color=165,70,113>" + Math.Round(dq, 2, MidpointRounding.ToEven).ToString().TrimEnd('0') + '%';
                }
            }
            previousData = data;
            index++;*/
        }

        public void UpdateStat(ProfilPenetrationView profilPenetrationView)
        {
            //ccSexe.DataSource = ProfilPenetrationView.ProfilPenetrationSupport.First().StatistiqueSexe;
            ccInstruction.Series.Clear();
            var series1 = new Series("A Pie Series", ViewType.Pie);

            series1.Points.Add(new SeriesPoint("Sans Instruc", profilPenetrationView.ProfilPrincipale.ProfilPrincipale.StatistiqueInstruction.SansInstruction));
            series1.Points.Add(new SeriesPoint("Lire Ecrire", profilPenetrationView.ProfilPrincipale.ProfilPrincipale.StatistiqueInstruction.SansInstructionLireEtEcrire));
            series1.Points.Add(new SeriesPoint("Primaire", profilPenetrationView.ProfilPrincipale.ProfilPrincipale.StatistiqueInstruction.Primaire));
            series1.Points.Add(new SeriesPoint("Moyen", profilPenetrationView.ProfilPrincipale.ProfilPrincipale.StatistiqueInstruction.Moyen));
            series1.Points.Add(new SeriesPoint("Secondaire", profilPenetrationView.ProfilPrincipale.ProfilPrincipale.StatistiqueInstruction.Secondaire));
            series1.Points.Add(new SeriesPoint("Universitaire", profilPenetrationView.ProfilPrincipale.ProfilPrincipale.StatistiqueInstruction.Universitaire));
            series1.SeriesPointsSortingKey =SeriesPointKey.Value_1;ccInstruction.Series.Add(series1);

            // Format the the series labels.
            series1.Label.TextPattern = "{A}: {VP:p0}";
        }



        private void OnCustomDrawElement(object sender, DevExpress.XtraGauges.Core.Primitive.CustomDrawElementEventArgs e)
        {

        }

        private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void tableLayoutPanel2_Paint(object sender, PaintEventArgs e)
        {

        }

        private void Secondaire_Click(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }
    }
}
